package file;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class TestFileUpload {

    /**
     * 导入 jar 包 common-fileupload, common-io, 配置 MultipartResolver 文件上传的表单中
     * checkbox 多选无 bug 文件下载见 handle.TestHandleJson#testResponseEntity
     */
    @RequestMapping("/testFileUpload")
    public String testFileUpload(@RequestParam("desc") String desc,
            @RequestParam(value = "type", required = false, defaultValue = "") String[] type,
            @RequestParam("file") MultipartFile file) throws IOException {
        System.out.println(desc);
        System.out.println(type.length);
        System.out.println(file.getOriginalFilename());
        System.out.println(file.getInputStream());
        return "success";
    }
}
